We free things from the text property MemChunk, so it needs to be
authorOwen Taylor <otaylor@redhat.com>
Tue, 21 Jul 1998 19:31:38 +0000 (19:31 +0000)
committerOwen Taylor <otaylor@src.gnome.org>
Tue, 21 Jul 1998 19:31:38 +0000 (19:31 +0000)
Wed Jul 15 17:44:47 1998  Owen Taylor  <otaylor@redhat.com>

* gtk/gtktext.c (new_text_property): We free things from
the text property MemChunk, so it needs to be G_ALLOC_AND_FREE.

* Fix up line start cache when splitting a property
during an insert.

ChangeLog
ChangeLog.pre-2-0
ChangeLog.pre-2-10
ChangeLog.pre-2-2
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
gtk/gtktext.c

index fdcb3d9b7e747a2166e335b35d8e79df7a944364..25ff25730f7ecb2d5255e6a28523dd0db7124320 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+Wed Jul 15 17:44:47 1998  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtktext.c (new_text_property): We free things from
+       the text property MemChunk, so it needs to be G_ALLOC_AND_FREE.
+
+       * Fix up line start cache when splitting a property
+       during an insert.
+
 1998-07-20  Raph Levien  <raph@acm.org>
 
        * gdk/gdkrgb.c: More cleanups in the config process.
index fdcb3d9b7e747a2166e335b35d8e79df7a944364..25ff25730f7ecb2d5255e6a28523dd0db7124320 100644 (file)
@@ -1,3 +1,11 @@
+Wed Jul 15 17:44:47 1998  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtktext.c (new_text_property): We free things from
+       the text property MemChunk, so it needs to be G_ALLOC_AND_FREE.
+
+       * Fix up line start cache when splitting a property
+       during an insert.
+
 1998-07-20  Raph Levien  <raph@acm.org>
 
        * gdk/gdkrgb.c: More cleanups in the config process.
index fdcb3d9b7e747a2166e335b35d8e79df7a944364..25ff25730f7ecb2d5255e6a28523dd0db7124320 100644 (file)
@@ -1,3 +1,11 @@
+Wed Jul 15 17:44:47 1998  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtktext.c (new_text_property): We free things from
+       the text property MemChunk, so it needs to be G_ALLOC_AND_FREE.
+
+       * Fix up line start cache when splitting a property
+       during an insert.
+
 1998-07-20  Raph Levien  <raph@acm.org>
 
        * gdk/gdkrgb.c: More cleanups in the config process.
index fdcb3d9b7e747a2166e335b35d8e79df7a944364..25ff25730f7ecb2d5255e6a28523dd0db7124320 100644 (file)
@@ -1,3 +1,11 @@
+Wed Jul 15 17:44:47 1998  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtktext.c (new_text_property): We free things from
+       the text property MemChunk, so it needs to be G_ALLOC_AND_FREE.
+
+       * Fix up line start cache when splitting a property
+       during an insert.
+
 1998-07-20  Raph Levien  <raph@acm.org>
 
        * gdk/gdkrgb.c: More cleanups in the config process.
index fdcb3d9b7e747a2166e335b35d8e79df7a944364..25ff25730f7ecb2d5255e6a28523dd0db7124320 100644 (file)
@@ -1,3 +1,11 @@
+Wed Jul 15 17:44:47 1998  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtktext.c (new_text_property): We free things from
+       the text property MemChunk, so it needs to be G_ALLOC_AND_FREE.
+
+       * Fix up line start cache when splitting a property
+       during an insert.
+
 1998-07-20  Raph Levien  <raph@acm.org>
 
        * gdk/gdkrgb.c: More cleanups in the config process.
index fdcb3d9b7e747a2166e335b35d8e79df7a944364..25ff25730f7ecb2d5255e6a28523dd0db7124320 100644 (file)
@@ -1,3 +1,11 @@
+Wed Jul 15 17:44:47 1998  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtktext.c (new_text_property): We free things from
+       the text property MemChunk, so it needs to be G_ALLOC_AND_FREE.
+
+       * Fix up line start cache when splitting a property
+       during an insert.
+
 1998-07-20  Raph Levien  <raph@acm.org>
 
        * gdk/gdkrgb.c: More cleanups in the config process.
index fdcb3d9b7e747a2166e335b35d8e79df7a944364..25ff25730f7ecb2d5255e6a28523dd0db7124320 100644 (file)
@@ -1,3 +1,11 @@
+Wed Jul 15 17:44:47 1998  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtktext.c (new_text_property): We free things from
+       the text property MemChunk, so it needs to be G_ALLOC_AND_FREE.
+
+       * Fix up line start cache when splitting a property
+       during an insert.
+
 1998-07-20  Raph Levien  <raph@acm.org>
 
        * gdk/gdkrgb.c: More cleanups in the config process.
index f15d62f23a0c7523202b021460bf1bc877a3c397..68bbdcb100691bc407ca2e867df257c9ad083381 100644 (file)
@@ -2457,12 +2457,31 @@ delete_expose (GtkText* text, guint nchars, guint old_lines, guint old_pixels)
 static void
 correct_cache_insert (GtkText* text, gint nchars)
 {
-  GList* cache = text->current_line->next;
+  GList *cache;
+  GtkPropertyMark *start;
+  GtkPropertyMark *end;
+  
+  /* If we split a property exactly at the beginning of the
+   * line, we have to correct here, or fetch_lines will
+   * fetch junk.
+   */
+
+  start = &CACHE_DATA(text->current_line).start;
+  if (start->offset == MARK_CURRENT_PROPERTY (start)->length)
+    SET_PROPERTY_MARK (start, start->property->next, 0);
+
+  /* Now correct the offsets, and check for start or end marks that
+   * are after the point, yet point to a property before the point's
+   * property. This indicates that they are meant to point to the
+   * second half of a property we split in insert_text_property(), so
+   * we fix them up that way.  
+   */
+  cache = text->current_line->next;
 
   for (; cache; cache = cache->next)
     {
-      GtkPropertyMark *start = &CACHE_DATA(cache).start;
-      GtkPropertyMark *end = &CACHE_DATA(cache).end;
+      start = &CACHE_DATA(cache).start;
+      end = &CACHE_DATA(cache).end;
 
       if (LAST_INDEX (text, text->point) &&
          start->index == text->point.index)
@@ -2472,7 +2491,16 @@ correct_cache_insert (GtkText* text, gint nchars)
          if (start->property == text->point.property)
            move_mark_n(start, nchars);
          else
-           start->index += nchars;
+           {
+             if (start->property->next &&
+                 (start->property->next->next == text->point.property))
+               {
+                 g_assert (start->offset >=  MARK_CURRENT_PROPERTY (start)->length);
+                 start->offset -= MARK_CURRENT_PROPERTY (start)->length;
+                 start->property = text->point.property;
+               }
+             start->index += nchars;
+           }
        }
 
       if (LAST_INDEX (text, text->point) &&
@@ -2482,8 +2510,17 @@ correct_cache_insert (GtkText* text, gint nchars)
        {
          if (end->property == text->point.property)
            move_mark_n(end, nchars);
-         else
-           end->index += nchars;
+         else 
+           {
+             if (end->property->next &&
+                 (end->property->next->next == text->point.property))
+               {
+                 g_assert (end->offset >=  MARK_CURRENT_PROPERTY (end)->length);
+                 end->offset -= MARK_CURRENT_PROPERTY (end)->length;
+                 end->property = text->point.property;
+               }
+             end->index += nchars;
+           }
        }
 
       /*TEXT_ASSERT_MARK(text, start, "start");*/
@@ -2635,7 +2672,7 @@ new_text_property (GdkFont* font, GdkColor* fore, GdkColor* back, guint length)
       text_property_chunk = g_mem_chunk_new ("text property mem chunk",
                                             sizeof(TextProperty),
                                             1024*sizeof(TextProperty),
-                                            G_ALLOC_ONLY);
+                                            G_ALLOC_AND_FREE);
     }
 
   prop = g_chunk_new(TextProperty, text_property_chunk);
@@ -2768,6 +2805,10 @@ insert_text_property (GtkText* text, GdkFont* font,
     }
   else
     {
+      /* The following will screw up the line_start cache,
+       * we'll fix it up in correct_cache_insert
+       */
+      
       /* In the middle of forward_prop, if properties are equal,
        * just add to its length, else split it into two and splice
        * in a new one. */